﻿@model HotelManageSystem.Models.WageModelDetial
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"> </script>
<link href= "@Url.Content("~/Content/TelerikGrid.css")"rel="stylesheet" type="text/css" />
<style>
    select
    {
        height: 24px;
        width: 90%;
    }
    input
    {
        height: 23px;
        width: 70%;
    }
    textarea
    {
        max-width: 90%;
        max-height: 70px;
        min-width: 90%;
        min-height: 70px;
        resize: none;
    }
</style>
<script type="text/javascript">
    $(document).ready(function () {
        //让工资信息只读,应为工资的基数和比率设定后,这一块的工资都已经定下来了.
        $("input").attr("readonly", "readonly");
        //工资的扣除与补贴可以被编辑
        $("#TakeOff").removeAttr("readonly");
        $("#Subsidy").removeAttr("readonly");
        $("#Remark").removeAttr("readonly");

        //点击返回按钮要将Wage/WageSetIndex加载到content当中来
        //然后设置菜单session为Wage/WageSetIndex
        $("#return").click(function () {
            $.get("Wage/WageSetIndex", null, function (data) {
                $("#content").html(data);
            });
            $.post("HumanResources/SetSeesion", { u: "Wage/WageSetIndex" }, function () { });
        });
    });

    //表单提交时验证本月该员工工资发放记录是否添加过,也就是该员工当月的工资信息是否添加到数据库当中
    function onClick() {
        var id = $("#EmployeeId").attr("value");
        var wageDate = $("#WageDay").attr("value");
        var v;
        $.ajax({
            url: '/Wage/CheckIn',
            async: false,
            type: 'POST',
            data: { id: id, wageDate: wageDate },
            dataType: 'json',
            success: function (data) {
                v = data.Data.Value;
            }
        });
        if (v == "false") {
            alert("每位员工当月只能有一条工资发放记录\r\n如果有疑问请先将当前考勤数据删除");
            return false;
        }
        return true;
    }
</script>
<div class="t-widget t-grid" style="width: 100%; height: 100%">
    @using (Html.BeginForm("WageGrant", "Wage", FormMethod.Post))
    {
        @Html.ValidationSummary(true)
        <div class="t-edit-form-container" style="width: 100%;">
            <fieldset style="width: 100%; border: 0px;">
                <legend style="font-size: 20px;">工资发放登记：</legend>
                <table>
                    <tr>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.EmployeeId)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.EmployeeId)
                                @Html.ValidationMessageFor(model => model.EmployeeId)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.Name)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.Name)
                                @Html.ValidationMessageFor(model => model.Name)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.BasicWage)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.BasicWage)
                                @Html.ValidationMessageFor(model => model.BasicWage)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.BasicValue)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.BasicValue)
                                @Html.ValidationMessageFor(model => model.BasicValue)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.WageDay)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.WageDay)
                                @Html.ValidationMessageFor(model => model.WageDay)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.EndowmentAssurance)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.EndowmentAssurance)
                                @Html.ValidationMessageFor(model => model.EndowmentAssurance)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.MedicalInsurance)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.MedicalInsurance)
                                @Html.ValidationMessageFor(model => model.MedicalInsurance)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.UnemploymentInsurance)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.UnemploymentInsurance)
                                @Html.ValidationMessageFor(model => model.UnemploymentInsurance)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.EmploymentInjuryInsurance)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.EmploymentInjuryInsurance)
                                @Html.ValidationMessageFor(model => model.EmploymentInjuryInsurance)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.MaternityInsurance)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.MaternityInsurance)
                                @Html.ValidationMessageFor(model => model.MaternityInsurance)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.ProvidentFund)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.ProvidentFund)
                                @Html.ValidationMessageFor(model => model.ProvidentFund)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.TakeOff)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.TakeOff)
                                @Html.ValidationMessageFor(model => model.TakeOff)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.Subsidy)
                            </div>
                            <div class="editor-field">
                                @Html.EditorFor(model => model.Subsidy)
                                @Html.ValidationMessageFor(model => model.Subsidy)
                            </div>
                        </td>
                        <td>
                            <div class="editor-label">
                                @Html.LabelFor(model => model.Remark)
                            </div>
                            <div class="editor-field">
                                @Html.TextAreaFor(model => model.Remark)
                                @Html.ValidationMessageFor(model => model.Remark)
                            </div>
                        </td>
                    </tr>
                </table>
                <p>
                    <input type="submit" value="提交" onclick="return onClick()" style="height: 23px; width: 5%;" />
                    <input type="button" value="返回" id="return" style="height: 23px; width: 5%;" />
                </p>
            </fieldset>
        </div>
    }
</div>
